package com.szgz.platform.result;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

public class PageResult<T> {
	private long total;
	private long pages;
	private long pageNum;
	private long pageSize;
	private List<T> records;

	public PageResult() {}

	public PageResult(long total, long pages, long pageNum, long pageSize, List<T> records) {
		this.total = total;
		this.pages = pages;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.records = records;
	}

	public static <T> PageResult<T> from(Page<T> page) {
		return new PageResult<>(page.getTotal(), page.getPages(), page.getCurrent(), page.getSize(), page.getRecords());
	}

	public long getTotal() { return total; }
	public void setTotal(long total) { this.total = total; }

	public long getPages() { return pages; }
	public void setPages(long pages) { this.pages = pages; }

	public long getPageNum() { return pageNum; }
	public void setPageNum(long pageNum) { this.pageNum = pageNum; }

	public long getPageSize() { return pageSize; }
	public void setPageSize(long pageSize) { this.pageSize = pageSize; }

	public List<T> getRecords() { return records; }
	public void setRecords(List<T> records) { this.records = records; }
}

